package rs.fon.is.music.domain;

import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;

import thewebsemantic.Namespace;
import thewebsemantic.RdfProperty;
import thewebsemantic.RdfType;
import rs.fon.is.music.util.Constants;

@Namespace(Constants.SCHEMA)
@RdfType("MusicGroup")
public class MusicGroup extends Thing{
	
	@RdfProperty(Constants.SCHEMA+ "interactionCount")
	private String interactionCount;
	
	@RdfProperty(Constants.SCHEMA + "foundingDate")
	private Date foundingDate;
	
	@RdfProperty(Constants.SCHEMA + "tracks")
	private Collection<MusicRecording> tracks;
	
	@RdfProperty(Constants.SCHEMA + "albums")
	private Collection<MusicAlbum> albums;
	
	@RdfProperty(Constants.SCHEMA + "event")
	private Collection<Event> events;

	public MusicGroup() {
		this.tracks = new LinkedList<>();
		this.albums = new LinkedList<>();
		this.events = new LinkedList<>();
	}
	
	public String getInteractionCount() {
		return interactionCount;
	}

	public void setInteractionCount(String interactionCount) {
		this.interactionCount = interactionCount;
	}

	public Date getFoundingDate() {
		return foundingDate;
	}

	public void setFoundingDate(Date foundingDate) {
		this.foundingDate = foundingDate;
	}

	public Collection<MusicRecording> getTracks() {
		return tracks;
	}

	public void setTracks(Collection<MusicRecording> tracks) {
		this.tracks = tracks;
	}

	public Collection<MusicAlbum> getAlbums() {
		return albums;
	}

	public void setAlbums(Collection<MusicAlbum> albums) {
		this.albums = albums;
	}

	public Collection<Event> getEvents() {
		return events;
	}

	public void setEvents(Collection<Event> events) {
		this.events = events;
	}
	
	public void addTrack(MusicRecording mr) {
		this.tracks.add(mr);
	}
	
	public void addTracks(Collection<MusicRecording> mrs) {
		this.tracks.addAll(mrs);
	}
	
	public void addAlbum(MusicAlbum a) {
		this.albums.add(a);
	}
	
	public void addEvent(Event e) {
		this.events.add(e);
	}
	
	@Override
	public String toString() {
		
		int year = 0;
		if(getFoundingDate()!=null)
			year = 1900 +  getFoundingDate().getYear();
		
		String s = "\nMusic group: "+ getName() 
				+ "\nURI: " + getUri() 
				+ "\nURL: " + getUrl() 
				+ "\nimage: " + getImage() 
				+ "\nfounding date: " + year 
				+ "\ninteraction count: " + getInteractionCount();
		
		if(getAlbums().size()>0){
			for (MusicAlbum a : getAlbums()) {
				s += "\n\n" + a.toString();
			}
		}
		
		/*if(getEvents().size()>0){
			for (Event e : getEvents()) {
				s += "\n\n" + e.toString();
			}
		}*/

		return s;
	}
	
	
}
